﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BartonExtension
{
    public static  class JsonCharacterCoder
    {
        const string DouHao = "x10000";
        const string YinHao = "x10001";
        const string MaoHao = "x10002";
        const string FenHao = "x10003";
        public static string encode(this string str)
        {
            return str.Replace(",", DouHao)
                      .Replace(":", MaoHao)
                      .Replace(";", FenHao)
                      .Replace("\"", YinHao);
        }

        public static string decode(this string str)
        {
            return str.Replace(DouHao, ",")
                      .Replace(MaoHao, ":")
                      .Replace(FenHao, ";")
                      .Replace(YinHao, "\"");
        }
    }
}
